{% extends 'common.html'%}
    {% block content %}
        <div class="layui-row">
				<form class="layui-form layui-col-md12 we-search" id="form_gen_data">
					<div class="layui-inline">
                        <label class="layui-form-label">手机号前缀</label>
						<input class="layui-input" placeholder="手机号" name="phone_prefix" id="phone_prefix">
					</div>
					<div class="layui-inline">
                        <label class="layui-form-label">身份证</label>
                        <div class="layui-input-block">
                          <select name="idcard" lay-filter="aihao">
                            <option value="成年" selected>成年</option>
                            <option value="小于18岁">小于18岁</option>
                            <option value="随机">随机</option>
                          </select>
                        </div>
					</div>
                    <div class="layui-inline">
                        <label class="layui-form-label">银行卡</label>
                        <div class="layui-input-block">
                          <select name="bankcard" lay-filter="aihao">
                            <option value="随机分配">随机分配</option>
                            <option value="平安银行">平安银行</option>
                            <option value="工商银行">工商银行</option>
                            <option value="广发银行">广发银行</option>
                            <option value="农业银行">农业银行</option>
                            <option value="兴业银行">兴业银行</option>
                            <option value="邮政银行">邮政银行</option>
                            <option value="招商银行">招商银行</option>
                            <option value="中国银行">中国银行</option>
                            <option value="建设银行">建设银行</option>
                            <option value="华夏银行">华夏银行</option>
                            <option value="浦发银行">浦发银行</option>
                            <option value="民生银行">民生银行</option>
                            <option value="光大银行" selected>光大银行</option>
                          </select>
                        </div>
					</div>
                    <div class="layui-inline">
                        <label class="layui-form-label">生成个数</label>
						<input class="layui-input" placeholder="生成个数" name="data_num" id="data_num" value="1">
					</div>
                </br></br>
                    <div class="layui-inline">

                        <div class="layui-input-block">
                            <input type="checkbox" name="is_whitelist" title="开白名单">
                            <select name="whitelist_system" lay-filter="aihao">
                                <option value="循环贷" selected>循环贷</option>
                                <option value="轻生活贷">轻生活贷</option>
                                <option value="分期商城">分期商城</option>
                                <option value="融360">融360</option>
                            </select>
                        </div>
					</div>

                    <div class="layui-inline">

                        <div class="layui-input-block">
                            <input type="checkbox" name="is_member" title="开通会员">
                            <select name="member_type" lay-filter="aihao">
                                <option value="随机会员">随机会员</option>
                                <option value="黄金年卡" selected="">黄金年卡</option>
                                <option value="白金年卡">白金年卡</option>
                                <option value="钻石年卡">钻石年卡</option>
                                <option value="黄金季卡">黄金季卡</option>
                                <option value="白金季卡">白金季卡</option>
                                <option value="钻石季卡">钻石季卡</option>
                                <option value="黄金体验卡">黄金体验卡</option>
                                <option value="白金体验卡">白金体验卡</option>
                                <option value="钻石体验卡">钻石体验卡</option>
                                <option value="信而富148黄金体验卡">信而富148黄金体验卡</option>
                            </select>
                        </div>
					</div>
                    <div class="layui-inline">
                        <label class="layui-form-label">会员类型</label>
                        <div class="layui-input-block">
                          <select name="member_system" lay-filter="aihao">
                            <option value="消费贷" selected>消费贷</option>
                            <option value="轻生活">轻生活</option>
                          </select>
                        </div>
					</div>
                    <div class="layui-inline">

                        <div class="layui-input-block">
                            <input type="checkbox" name="is_register" title="注册">
                            <input type="checkbox" name="is_bindcard" title="绑卡">
                        </div>
					</div>
				</form>
			</div>
			<div class="weadmin-block">
				<button class="layui-btn" id="gen_data"><i class="layui-icon"></i>开始生成</button>
				<button class="layui-btn" id="flush_data"><i class="layui-icon"></i>刷新</button>
			</div>
            <table class="layui-hide" id="table_data_task" lay-filter="table_data_task"></table>

            <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>
            <script type="text/javascript">
                layui.use('table', function(){
                        var table = layui.table;
                        //方法级渲染
                        table.render({
                            elem: '#table_data_task'
                            ,url: '/tools/data_task'
                            ,method:'post'
                            ,where:{openid:parent.window.openid,env_tools:parent.window.env_tools}
                            ,cellMinWidth: 100
                            ,cols: [[
                                {checkbox: true, fixed: true}
                                ,{field:'id', title: 'ID', sort: true, fixed: true,width:80}
                                ,{field:'phone_prefix', title: '手机号前缀',width:120}
                                ,{field:'idcard', title: '身份证',width:90}
                                ,{field:'bankcard', title: '绑卡类型',width:90}
                                ,{field:'is_whitelist', title: '白名单',width:80}
                                ,{field:'whitelist_system', title: '白名单类型'}
                                ,{field:'is_member', title: '会员',width:80}
                                ,{field:'member_type', title: '会员类型'}
                                ,{field:'member_system', title: '会员分类'}
                                ,{field:'is_register', title: '是否注册'}
                                ,{field:'is_bindcard', title: '是否绑卡'}
                                ,{field:'data_num', title: '数量',width:80}
                                ,{field:'status', title: '状态',width:100,templet: function(d){
                                    var status = '';
                                    if(d.status == 0){
                                        status='待处理';
                                    }else if(d.status == 1){
                                        status='处理中';
                                    }else if(d.status == 2){
                                        status='处理完成';
                                    }
                                    return status;
                                }}
                                ,{field:'create_time', title: '创建时间'}
                                ,{field:'finish_time', title: '完成时间'}
                                ,{field:'status', title: '操作',templet: function(d){
                                    return '<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>';
                                }}
                            ]]
                            ,id: 'table_data_task'
                            ,page: true
                            ,height: 500
                        });
                        //监听工具条
                          table.on('tool(table_data_task)', function(obj){
                            var data = obj.data;
                            if(obj.event === 'detail'){
                              var index = layer.open({
                                type: 2,
                                maxmin: true,
                                shadeClose: true,
                                shade: 0.4,
                                title: '查看',
                                content: '/tools/data_task/query?taskid='+data.id,
                            });
                              layer.full(index);
                            }
                          });

                        var $ = layui.$, active = {
                            reload: function(){
                                //执行重载
                                table.reload('table_data_task', {
                                    page: {
                                        curr: 1 //重新从第 1 页开始
                                    }
                                    ,where: {
                                        openid:parent.window.openid,
                                        env_tools:parent.window.env_tools
                                    }
                                });
                            }
                        };

                        $('#flush_data').on('click', function(){
                            active['reload'] ? active['reload'].call(this) : '';
                        });
                        $('#gen_data').on('click', function(){
                            var form_data = $("#form_gen_data").serialize()
                            form_data = form_data + '&openid='+ parent.window.openid + '&env_tools='+parent.window.env_tools
                            $.ajax({
                                type: 'post',
                                url: '/tools/data_task/add',
                                data: form_data,
                                success: function(data) {
                                    layer.msg(data.message);
                                    active['reload'] ? active['reload'].call(this) : '';
                                }
                            });

                        });
                    });
            </script>
    {% endblock %}